package com.bbva.kyfb.kyfbjpatlbh.dominiotlbh;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.Id;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class Ttlsbdiv.
 */
@Entity
@Table(name = "TTLSBDIV",schema = "TLSB")
@Configurable
@RooJavaBean
@RooToString
@RooEntity(versionField = "",  persistenceUnit="persistenceUnitTLBH",table = "TTLSBDIV", schema = "TLSB")
@PersistenceContext(unitName="persistenceUnitTLBH")
@RooDbManaged(automaticallyDelete = true)
public class Ttlsbdiv {

	/** The cod abreviat. */
	@Column(name = "COD_ABREVIAT",columnDefinition = "CHAR", length = 3)
    private String codAbreviat;

	/** The des diisoalf. */
	@Column(name = "DES_DIISOALF",columnDefinition = "CHAR", length = 40)
    private String desDiisoalf;

	/** The qty euro. */
	@Column(name = "QTY_EURO", columnDefinition = "DECIMAL",precision = 12, scale = 6)
    private BigDecimal qtyEuro;

	/** The xsn decimal. */
	@Column(name = "XSN_DECIMAL",columnDefinition = "CHAR", length=1)
    private Character xsnDecimal;

	/** The xsn moneuro. */
	@Column(name = "XSN_MONEURO",columnDefinition = "CHAR", length=1)
    private Character xsnMoneuro;

	/** The cod unidcamb. */
	@Column(name = "COD_UNIDCAMB",columnDefinition = "DECIMAL")
    private BigDecimal codUnidcamb;

	/** The aud fmodific. */
	@Column(name = "AUD_FMODIFIC", columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date audFmodific;

	/** The aud usuario. */
	@Column(name = "AUD_USUARIO",columnDefinition = "CHAR", length = 8)
    @NotNull
    private String audUsuario;

	/**
	 * Gets the cod abreviat.
	 *
	 * @return the cod abreviat
	 */
	public String getCodAbreviat() {
        return this.codAbreviat;
    }

	/**
	 * Sets the cod abreviat.
	 *
	 * @param codAbreviat the new cod abreviat
	 */
	public void setCodAbreviat(String codAbreviat) {
        this.codAbreviat = codAbreviat;
    }

	/**
	 * Gets the des diisoalf.
	 *
	 * @return the des diisoalf
	 */
	public String getDesDiisoalf() {
        return this.desDiisoalf;
    }

	/**
	 * Sets the des diisoalf.
	 *
	 * @param desDiisoalf the new des diisoalf
	 */
	public void setDesDiisoalf(String desDiisoalf) {
        this.desDiisoalf = desDiisoalf;
    }

	/**
	 * Gets the qty euro.
	 *
	 * @return the qty euro
	 */
	public BigDecimal getQtyEuro() {
        return this.qtyEuro;
    }

	/**
	 * Sets the qty euro.
	 *
	 * @param qtyEuro the new qty euro
	 */
	public void setQtyEuro(BigDecimal qtyEuro) {
        this.qtyEuro = qtyEuro;
    }

	/**
	 * Gets the xsn decimal.
	 *
	 * @return the xsn decimal
	 */
	public Character getXsnDecimal() {
        return this.xsnDecimal;
    }

	/**
	 * Sets the xsn decimal.
	 *
	 * @param xsnDecimal the new xsn decimal
	 */
	public void setXsnDecimal(Character xsnDecimal) {
        this.xsnDecimal = xsnDecimal;
    }

	/**
	 * Gets the xsn moneuro.
	 *
	 * @return the xsn moneuro
	 */
	public Character getXsnMoneuro() {
        return this.xsnMoneuro;
    }

	/**
	 * Sets the xsn moneuro.
	 *
	 * @param xsnMoneuro the new xsn moneuro
	 */
	public void setXsnMoneuro(Character xsnMoneuro) {
        this.xsnMoneuro = xsnMoneuro;
    }

	/**
	 * Gets the cod unidcamb.
	 *
	 * @return the cod unidcamb
	 */
	public BigDecimal getCodUnidcamb() {
        return this.codUnidcamb;
    }

	/**
	 * Sets the cod unidcamb.
	 *
	 * @param codUnidcamb the new cod unidcamb
	 */
	public void setCodUnidcamb(BigDecimal codUnidcamb) {
        this.codUnidcamb = codUnidcamb;
    }

	/**
	 * Gets the aud fmodific.
	 *
	 * @return the aud fmodific
	 */
	public Date getAudFmodific() {
        return this.audFmodific;
    }

	/**
	 * Sets the aud fmodific.
	 *
	 * @param audFmodific the new aud fmodific
	 */
	public void setAudFmodific(Date audFmodific) {
        this.audFmodific = audFmodific;
    }

	/**
	 * Gets the aud usuario.
	 *
	 * @return the aud usuario
	 */
	public String getAudUsuario() {
        return this.audUsuario;
    }

	/**
	 * Sets the aud usuario.
	 *
	 * @param audUsuario the new aud usuario
	 */
	public void setAudUsuario(String audUsuario) {
        this.audUsuario = audUsuario;
    }

	/** The entity manager. */
	@PersistenceContext
    transient EntityManager entityManager;

	/** The cod diisoalf. */
	@Id
    @Column(name = "COD_DIISOALF",columnDefinition = "CHAR", length = 3)
    private String codDiisoalf;

	/**
	 * Gets the cod diisoalf.
	 *
	 * @return the cod diisoalf
	 */
	public String getCodDiisoalf() {
        return this.codDiisoalf;
    }

	/**
	 * Sets the cod diisoalf.
	 *
	 * @param id the new cod diisoalf
	 */
	public void setCodDiisoalf(String id) {
        this.codDiisoalf = id;
    }

	/**
	 * Persist.
	 */
	@Transactional(value="tlbh")
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	/**
	 * Removes the.
	 */
	@Transactional(value="tlbh")
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Ttlsbdiv attached = Ttlsbdiv.findTtlsbdiv(this.codDiisoalf);
            this.entityManager.remove(attached);
        }
    }

	/**
	 * Flush.
	 */
	@Transactional(value="tlbh")
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	/**
	 * Clear.
	 */
	@Transactional(value="tlbh")
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	/**
	 * Merge.
	 *
	 * @return the ttlsbdiv
	 */
	@Transactional(value="tlbh")
    public Ttlsbdiv merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Ttlsbdiv merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }

	/**
	 * Entity manager.
	 *
	 * @return the entity manager
	 */
	public static final EntityManager entityManager() {
        EntityManager em = new Ttlsbdiv().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	
	/**
	 * Count ttlsbdivs.
	 *
	 * @return the long
	 */
	@Transactional(value="tlbh")
	public static long countTtlsbdivs() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Ttlsbdiv o", Long.class).getSingleResult();
    }

	
	/**
	 * Find all ttlsbdivs.
	 *
	 * @return the list
	 */
	@Transactional(value="tlbh")
	public static List<Ttlsbdiv> findAllTtlsbdivs() {
        return entityManager().createQuery("SELECT o FROM Ttlsbdiv o", Ttlsbdiv.class).getResultList();
    }

	
	/**
	 * Find ttlsbdiv.
	 *
	 * @param codDiisoalf the cod diisoalf
	 * @return the ttlsbdiv
	 */
	@Transactional(value="tlbh")
	public static Ttlsbdiv findTtlsbdiv(String codDiisoalf) {
        if (codDiisoalf == null || codDiisoalf.length() == 0) return null;
        return entityManager().find(Ttlsbdiv.class, codDiisoalf);
    }

	
	/**
	 * Find ttlsbdiv entries.
	 *
	 * @param firstResult the first result
	 * @param maxResults the max results
	 * @return the list
	 */
	@Transactional(value="tlbh")
	public static List<Ttlsbdiv> findTtlsbdivEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Ttlsbdiv o", Ttlsbdiv.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AudFmodific: ").append(getAudFmodific()).append(", ");
        sb.append("AudUsuario: ").append(getAudUsuario()).append(", ");
        sb.append("CodAbreviat: ").append(getCodAbreviat()).append(", ");
        sb.append("CodDiisoalf: ").append(getCodDiisoalf()).append(", ");
        sb.append("CodUnidcamb: ").append(getCodUnidcamb()).append(", ");
        sb.append("DesDiisoalf: ").append(getDesDiisoalf()).append(", ");
        sb.append("QtyEuro: ").append(getQtyEuro()).append(", ");
        sb.append("XsnDecimal: ").append(getXsnDecimal()).append(", ");
        sb.append("XsnMoneuro: ").append(getXsnMoneuro());
        return sb.toString();
    }
}
